<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../react/react17.development.js"></script>
    <script src="../react/react-dom17.development.js"></script>
    <script src="../react/babel.min.js"></script>
</head>

<body>
    <div id="main"></div>
    <script type="text/babel">
        // class 组件名    extends 继承的父类名
        class Com extends React.Component {
            // render()  会被直接调用  属于生命周期函数的一个
            // 主要负责渲染jsx
            // 类组件中 唯一一个必须实现的生命周期函数
            render() {
                console.log(this);  // 当前组件对象
                console.log(this.props);
                let arr = ['aaa', 'bbb', 'ccc'];
                return (<div>
                    <h2>这是com组件</h2>
                    <p>{this.props['user-name']}</p>
                    <p>{this.props.ageUa}</p>

                    <ul>
                        <ComTwo />
                        {arr.map((item, index) => (<ComTwo item={item}
                            key={index} />))}
                    </ul>
                </div>)
            }
        }

        class ComTwo extends React.Component {
            render() {
                console.log(this.props);
                return (<li>
                    这是li
                    <a href=''>
                        {this.props.item}
                    </a>
                </li>)
            }
        }

        ReactDOM.render(<Com user-name='nana' ageUa={18} />,
            document.getElementById('main'));
    </script>
</body>

</html>